.ng-image-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  background: transparent;

  &--visible {
    opacity: 1;
    pointer-events: auto;

    .ng-image-preview-overlay__container {
      --np-scale: 1;
      opacity: 1;
    }
  }

  &__mask {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 0;
  }

  &__container {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    --np-drag-x: 0px;
    --np-drag-y: 0px;
    --np-scale: 0.97;
    opacity: 0;
    transform: translate3d(var(--np-drag-x), var(--np-drag-y), 0) scale(var(--np-scale));
    transition: transform 0.24s ease, opacity 0.24s ease;
  }

  &__close {
    position: absolute;
    top: 24px;
    right: 24px;
    z-index: 2;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
    pointer-events: auto;

    span {
      display: block;
      font-size: 26px;
      line-height: 1;
      transform: translateY(-1px);
    }

    &:hover {
      background: rgba(255, 255, 255, 0.18);
    }

    &:active {
      transform: scale(0.95);
    }
  }

  &__caption {
    position: absolute;
    top: 32px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    max-width: 70vw;
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    pointer-events: none;
  }

  &__image-wrapper {
    position: relative;
    z-index: 1;
    max-width: calc(100vw - 160px);
    max-height: calc(100vh - 160px);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    user-select: none;
    touch-action: none;
    cursor: default;
  }

  &__image {
    max-width: 100%;
    max-height: 100%;
    transform-origin: center center;
    transition: transform 0.24s ease;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
    border-radius: 4px;
  }

  &__image-wrapper--draggable {
    cursor: grab;
  }

  &__image-wrapper--dragging {
    cursor: grabbing;

    .ng-image-preview-overlay__image {
      transition: none;
    }
  }

  &__toolbar {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 40px;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
    pointer-events: auto;
  }

  &__toolbar-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
  }

  &__toolbar-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
  }

  &__toolbar-btn:active:not(:disabled) {
    transform: scale(0.94);
  }

  &__toolbar-btn:disabled {
    color: rgba(255, 255, 255, 0.35);
    cursor: not-allowed;
  }

  &__toolbar-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.16);
    margin: 0 4px;
    pointer-events: none;
  }

  &__toolbar-text {
    padding: 0 12px;
    min-width: 56px;
    text-align: center;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1;
    font-variant-numeric: tabular-nums;
  }

  &__icon {
    width: 20px;
    height: 20px;
    display: inline-block;
    color: inherit;

    * {
      transition: stroke 0.2s ease, fill 0.2s ease;
    }
  }

  &__icon--rotate-left {
    transform: scaleX(-1);
    transform-origin: center;
  }

  &__icon--rotate-right {
    transform: none;
  }

  @media (max-width: 768px) {
    &__close {
      top: 16px;
      right: 16px;
      width: 38px;
      height: 38px;

      span {
        font-size: 22px;
      }
    }

    &__caption {
      top: 22px;
      max-width: 80vw;
      font-size: 13px;
    }

    &__image-wrapper {
      max-width: calc(100vw - 48px);
      max-height: calc(100vh - 120px);
    }

    &__toolbar {
      bottom: 24px;
      padding: 6px;
    }

    &__toolbar-btn {
      width: 36px;
      height: 36px;
    }

    &__toolbar-text {
      padding: 0 10px;
      min-width: 48px;
      font-size: 13px;
    }
  }
}

.ng-image-preview-open {
  overflow: hidden;
}

.ng-image-preview-trigger {
  cursor: zoom-in;
}
